<%@ Page Language="C#" AutoEventWireup="true" Inherits="Home" Codebehind="Home.aspx.cs" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Untitled Page</title>
    <link href="Css/Layout.css" rel="stylesheet" type="text/css"/>     
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <span class="title">What can I do with Pampa.Net?</span>
        <br/>
        <br/>
        To list entities, to define filters for a list, to define actions for each item and much more things related to lists. 
        Also, it is possible to define how an entity will be edited, including: validations, field dependencies, repetitive properties, grouping fields, permissions and much more things related to edit pages. 
        <br/><br/>
        For the edition you can use a wide range of controls including: textboxes, dropdownlists, multiselection lists, datepickers and more.
        Most of them are custom controls included in a separated library called Pampa.WebControls and could be used separately.
        <br/><br/>
        To use the framework you just need to define your model and write an XML file for each entity in your model.
        This XML define how an entity is listed and edited in a very easy and understandable way.
        <br/>
        <br/>
        <br/>
        
        
        <span class="title">A Very Simple Example...</span>
        <br/>
        <br/>
        Suppose we have a set of books; each book has the following properties: Author, Title, Type and Abstract.
        So, we have to show a list of all books, and give the user the possibility of: <br/>
            1- Create a new book <br/>
            2- Edit properties of a book in the list <br/> 
            3- Delete a book from the list <br/>
        <br/>
            
        This is a typical scenario of a CRUD application where normally we have lot of entities that we want to list, create, update and delete.
        
        So, after adding a few parameters in the web.config to configure the framework, 
        we have to model our class Book and implement persistence methods, which is almost trivial using Castle.ActiveRecord.
        <br/>

<pre class="codeBlock" style="width:auto">
<span class="keyword">public class</span> <span class="className">Book</span> : Pampa.CRUD.Core.<span class="className">IActiveRecord</span>
{
   <span class="keyword">private string</span> author;
   <span class="keyword">private string</span> title;
   <span class="keyword">private BookType</span> type;
   <span class="keyword">private string</span> abstract;
   
   <span class="keyword">public</span> Book()
   {
   } 

   <span class="keyword">public string</span> Author
   {
      <span class="keyword">get</span> { <span class="keyword">return</span> author; }
      <span class="keyword">set</span> { author = value; }
   }
 
   ...
    
   <span class="keyword">public void</span> Save()
   {
      ...
   }
   
   ...
} 
</pre>
        

		Then we define listing and edition properties of a book in a XML file (book.crud.xml)
		<br/>


<pre class="codeBlock">
&lt;xml version="1.0" encoding="utf-8" ?&gt;

&lt;entity xmlns="urn:pampa-config"&gt;
   &lt;grid&gt;
   &lt;Columns&gt;
      &lt;Column Field="ID" Title="ID" Type="Number" IsId="true" Visible="false"/&gt;
         &lt;Column Field="Title" Title="ID" Type="String" IsId="false" Visible="true"/&gt;
         &lt;Column Field="Type" Title="ID" Type="String" IsId="false" Visible="true"/&gt;
         &lt;Column Field="Author" Title="ID" Type="String" IsId="false" Visible="true"/&gt;
      &lt;/Columns&gt;
      &lt;Actions&gt;
         &lt;EditItemAction MethodName="editBook"/&gt;
         &lt;DeleteItemAction MethodName="deleteBook"/&gt;
      &lt;/Actions&gt;
   &lt;/grid&gt;	
   &lt;edit&gt;		
      &lt;HeaderGroup Id="MainData" Title="Book Data" Columns="1"&gt;
         &lt;Items&gt;
            &lt;TextItem Id="Title" Label="Title" LabelWidth="150" ValueWidth="200" MaxLength="20"&gt;
            &lt;/TextItem&gt;
            &lt;TextItem Id="Author" Label="Author" LabelWidth="150" ValueWidth="200" MaxLength="20"&gt;
            &lt;/TextItem&gt;
            &lt;EntityComboItem Id="Type" Label="Type" LabelWidth="150" ValueWidth="50" EntityName="Demo.Model.BookType, Demo.Model"&gt;
            &lt;/EntityComboItem&gt;
            &lt;TextItem Id="Abstract" Label="Abstract" LabelWidth="150" ValueWidth="200" ValueHeight="50" TextMode="MultiLine"&gt;
            &lt;/TextItem&gt;
         &lt;/Items&gt;
      &lt;/HeaderGroup&gt;
   &lt;/edit&gt;
&lt;/entity>
</pre>

    Notice that deleteBook and editBook are javascript functions. Typically, these functions call to an AJAX function where the work is done. 
    (If you download the demo you can see how to do that)        
    <br/>
    <br/>
    Finally, where we want to see a list of books we should use a CustomGrid control and where we want to edit a book we should use an EntityEdit control.
    Then, with a few lines in the code behind of the page we will have our list of books and book edition ready.
    </br>
    
<pre class="codeBlock">
&lt;cc1:EntityEdit ID="EntityEdit1" runat="server" Height="518px" Width="100%" CssClass="entityEdit"/&gt;
&lt;cc2:EntityEditSaveButton id="btnAccept" runat="server" text="Save" EntityEditID="EntityEdit1"/&gt;        
</pre>
    
<pre class="codeBlock">
<span class="className">Book</span> newBook = <span class="keyword">new</span> <span class="className">Book</span>();
EntityEdit1.Entity = newBook;
</pre>
    
<pre class="codeBlock">
&lt;cc3:CustomGrid id="CustomGrid1" runat="server" Height="269px" Width="100%" CssClass="customGrid" PageSize="10"/&gt;
&lt;cc3:BasicPager id="BasicPager1" runat="server" Width="100%" GridID="CustomGrid1"&gt;   
</pre>
    
<pre class="codeBlock">
CustomGrid1.LoadEntityConfiguration("Model.Book, Model");
</pre>   
 
    </div>
    </form>
</body>

<!-- Start of StatCounter Code -->
<script type="text/javascript">
var sc_project=5835170;
var sc_invisible=1;
var sc_security="ee53600e";
</script>

<script type="text/javascript"
src="http://www.statcounter.com/counter/counter.js"></script><noscript><div
class="statcounter"><a title="vBulletin analytics"
href="http://www.statcounter.com/vbulletin/"
target="_blank"><img class="statcounter"
src="http://c.statcounter.com/5835170/0/ee53600e/1/"
alt="vBulletin analytics" ></a></div></noscript>
<!-- End of StatCounter Code -->

</html>
